package com.yc.exam.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.exam.entity.Course;
import com.yc.exam.mapper.CourseMapper;
import com.yc.exam.service.ICourseService;
import com.yc.exam.vo.CourseVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 服务实现类
 *
 * @author 王妍
 * @since 2022-02-20
 */
@Service
@AllArgsConstructor
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

  private final CourseMapper courseMapper;

  @Override
  public Page<CourseVo> loadPage(Page<CourseVo> courseVoPage, CourseVo course) {
    return courseMapper.loadPageVo(courseVoPage, course);
  }

  @Override
  public Page<CourseVo> getSubscribed(Long studentId, Page<CourseVo> coursePage, CourseVo course) {
    return courseMapper.selectScribed(studentId, coursePage, course, true);
  }

  @Override
  public Page<CourseVo> getNoSubscribed(
      Long studentId, Page<CourseVo> coursePage, CourseVo course) {
    return courseMapper.selectScribed(studentId, coursePage, course, false);
  }
}
